package top.soulblack.purchasesale.mapper;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import top.soulblack.purchasesale.model.Role;
import java.util.List;

@Mapper
@Component
public interface RoleMapper {
    int deleteByPrimaryKey(Integer id);

    int deleteById(Integer id);

    int insert(Role name);

    Role selectByPrimaryKey(Integer id);

    @Select("select count(*) from user where role_id = #{id}")
    int userole(int id);

    @Delete("delete from `purchase_sale`.`role` where id = #{id}")
    int deleteID(int id);

    @Select("select * from role order by id")
    List<Role> selectAll();

    @Insert("insert into role (name) values (#{role})")
    void addRole(String role);

    @Select("select count(*) from role where name = #{name}")
    int existrole(String name);

    @Select("select count(*) from role where name = #{name}")
    List<Role> getrole(String name);

    @Update("update role set name = replace(name,#{oldname},#{name}) ")
    int updateRole(String name,String oldname);

    //@Insert("insert into role select * from role where name = #{name}")
    @Insert("insert into role (name) values (#{name})")
    int copyasNew(String name);

    int updateByPrimaryKey(Role name);

    int role(Integer id);
}